package com.lee.study.shouji.adapter;


import com.lee.study.shouji.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * @description 主界面UI的GridView的Adapter
 *
 * @author AlexLee
 *
 * @Create 2013-6-4 上午10:52:22
 */
public class MainUIAdapter extends BaseAdapter {

	public Context context;
	public LayoutInflater layoutInflater;
	public ImageView imageView;
	public TextView textView;
	
	/**
	 * 功能名称
	 */
	public static int[] names = {
		R.string.gv_01,
		R.string.gv_02,
		R.string.gv_03,
		R.string.gv_04,
		R.string.gv_05,
		R.string.gv_06,
		R.string.gv_07,
		R.string.gv_08,
		R.string.gv_09
	};
	/**
	 * 功能对应的icon
	 */
	public static int[] icons= {
		R.drawable.safe,
		R.drawable.callmsgsafe,
		R.drawable.app,
		R.drawable.taskmanager,
		R.drawable.netmanager,
		R.drawable.trojan,
		R.drawable.sysoptimize,
		R.drawable.atools,
		R.drawable.settings
	};
	
	public MainUIAdapter() {
	}
	
	public MainUIAdapter(Context context) {
		this.context = context;
		layoutInflater = LayoutInflater.from(context);
	}
	
	@Override
	public int getCount() {
		return names.length;
	}
	@Override
	public Object getItem(int position) {
		return position;
	}
	@Override
	public long getItemId(int position) {
		return position;
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		View view = layoutInflater.inflate(R.layout.gv_main_item, null);
		imageView = (ImageView) view.findViewById(R.id.gv_main_item_icon);
		textView = (TextView) view.findViewById(R.id.gv_main_item_text);
		
		imageView.setImageResource(icons[position]);
		textView.setText(names[position]);
		
		return view;
	}
	


}
